Skip to content

Ruby: Fix ExprReturnNode to handle Rescue, Ensure, and Else. - #22256

Draft
aschackmull wants to merge 1 commit into
github:mainfrom
aschackmull:ruby/implicitreturn
Draft

Ruby: Fix ExprReturnNode to handle Rescue, Ensure, and Else.#22256
aschackmull wants to merge 1 commit into
github:mainfrom
aschackmull:ruby/implicitreturn

Conversation

@aschackmull

@aschackmull aschackmull commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

As the test shows, ExprReturnNode failed to handle several cases, which this PR fixes. Also this avoids implicit assumptions about the structure of the CFG.

@github-actions github-actions Bot added the Ruby label Jul 30, 2026
@aschackmull
aschackmull force-pushed the ruby/implicitreturn branch from 27f0505 to 6ee164f Compare July 30, 2026 10:55
@aschackmull aschackmull changed the title Ruby: test implicit return refactor Ruby: Simplify ExprReturnNode to not rely on CFG Jul 30, 2026
@aschackmull aschackmull added the no-change-note-required This PR does not need a change note label Jul 30, 2026
@aschackmull
aschackmull marked this pull request as ready for review July 30, 2026 10:59
@aschackmull
aschackmull requested a review from a team as a code owner July 30, 2026 10:59
Copilot AI review requested due to automatic review settings July 30, 2026 10:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Simplifies Ruby expression-return detection by avoiding CFG structure assumptions.

Changes:

  • Adds a helper to resolve desugared AST nodes.
  • Identifies implicit returns from a callable’s final statement.
Show a summary per file
File Description
ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowPrivate.qll Refactors ExprReturnNode detection to use AST structure rather than CFG successors.

Review details

  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Medium

@aschackmull
aschackmull marked this pull request as draft July 31, 2026 07:07
@aschackmull
aschackmull force-pushed the ruby/implicitreturn branch from 6ee164f to 4aec6bd Compare July 31, 2026 13:25
@aschackmull aschackmull changed the title Ruby: Simplify ExprReturnNode to not rely on CFG Ruby: Fix ExprReturnNode to handle Rescue, Ensure, and Else. Aug 4, 2026
@aschackmull
aschackmull force-pushed the ruby/implicitreturn branch from 4aec6bd to c2f7db5 Compare August 4, 2026 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-change-note-required This PR does not need a change note Ruby

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants